﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using BUS;

namespace FastDeal.Control
{
    public partial class ThemDiaDiem : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDSDiaPhuong();
            }
        }
        DiaPhuong dp = new DiaPhuong();
        DiaPhuong_BUS dpBUS = new DiaPhuong_BUS();
        private void LoadDSDiaPhuong()
        {
            ddlDiaPhuong.DataSource = dpBUS.LayDanhSach_DiaPhuong();
            ddlDiaPhuong.DataTextField = "TenDiaPhuong";
            ddlDiaPhuong.DataValueField = "MaDiaPhuong";
            ddlDiaPhuong.DataBind();
        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            DiaDiem diadiem = new DiaDiem();
            DiaDiem_BUS ddBUS= new DiaDiem_BUS();
            diadiem.TenDiaDiem = txtTenDiaDiem.Text;
            diadiem.SoNha = txtSoNha.Text;
            diadiem.TenDuong = txtTenDuong.Text;
            diadiem.Phuong = txtPhuong.Text;
            diadiem.Quan = txtQuan.Text;
            diadiem.MaDiaPhuong = Convert.ToInt32(ddlDiaPhuong.SelectedValue);
            diadiem.DienThoai = txtDienThoai.Text;
            diadiem.KinhDo = txtKinhDo.Text;
            diadiem.ViDo = txtViDo.Text;
            ddBUS.Them_DiaDiem(diadiem);

            txtTenDiaDiem.Text = String.Empty;
            txtSoNha.Text = String.Empty;
            txtTenDuong.Text = String.Empty;
            txtPhuong.Text = String.Empty;
            txtQuan.Text = String.Empty;
            txtDienThoai.Text = String.Empty;
            txtKinhDo.Text = String.Empty;
            txtViDo.Text = String.Empty;
        }
    }
}   